<template>
	<view class="center">
		<view class="logo" @click="goLogin" :hover-class="!login ? 'logo-hover' : ''">
			<image class="logo-img" :src="login ? userInfo.avatar : ''"></image>
			<view class="logo-title">
				<text class="uer-name">Hi，{{ login ? userInfo.nickname : '您未登录' }}</text>
				<text class="uni-panel-icon uni-icon" v-if="!login">&#xe581;</text>
			</view>
			<text style="color: #ffffff;font-weight: 800;font-size: 20px;">{{ group[userData.userinfo.group_id] }}</text>
		</view>
		<view class="workData">
			<view>
				总提成：¥<span>{{ userData.userinfo.score }}</span>
			</view>
			<view class="performance">
				<view class="performance-item">
					<view>¥{{ userData.data.today_total }}</view>
					<view>今日预估</view>
				</view>
				<view class="performance-item">
					<view>¥{{ userData.data.month_total }}</view>
					<view>本月预估</view>
				</view>
				<view class="performance-item">
					<view>¥{{ userData.data.last_month_total }}</view>
					<view>上月预估</view>
				</view>
			</view>
			<view>
				每月25号可联系财务提现
			</view>
		</view>

		<u-cell-group class="m_top20">
			<u-cell-item icon="account" color='#22c1a9' title="帐号管理" @click="gourl('account')"></u-cell-item>
			<u-cell-item icon="order" color='#22c1a9' title="个人业绩" @click="gourl('../myEarning/myEarning')"></u-cell-item>
			<u-cell-item icon="coupon" color='#22c1a9' title="业绩排行" @click="gourl('../rank/rank')"></u-cell-item>
			<!-- <u-cell-item icon="chat-fill" color='#f3e5e9' title="新消息通知" @click="gourl('message')"></u-cell-item> -->
			<!-- <u-cell-item icon="question-circle-fill" color='#aaaaff' title="问题反馈" @click="gourl('feedback')"></u-cell-item>
			<u-cell-item icon="zhuanfa" color='#aa557f' title="服务条款及协议" @click="gourl('service')"></u-cell-item>
			<u-cell-item icon="error-circle-fill" color='#dc6a19' title="关于应用" @click="gourl('about')"></u-cell-item> -->
			<!-- <view v-if="userInfo.username == 'admin'">
				<u-cell-item icon="account" color='#358bc1' title="注册新用户" @click="gourl('../login/register')"></u-cell-item>
			</view> -->

		</u-cell-group>

		<u-cell-group class="m_top20">
		</u-cell-group>

	</view>
</template>

<script>
export default {
	data() {
		return {
			login: false,
			userInfo: {},
			userData: {},//用户数据
			group: ['', '销售', '生产', '管理员', '财务'],//用户组翻译
		}
	},
	onLoad() {
		let userinfo = uni.getStorageSync('userinfo');
		if (userinfo) {
			this.login = true;
		}
		this.getUserDetail()
		this.getUserData()

	},
	methods: {
		getUserData() {
			var _this = this;
			this._post_form('api/user/newgetUserDetail', {}, function (res) {
				console.log('%c [ res ]-75', 'font-size:13px; background:pink; color:#bf2c9f;', res)
				console.log('%c [ res.data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', res.data)
				if (res.code == 1) {
					_this.userData = res.data
					console.log('%c [ this.UserData ]-77', 'font-size:13px; background:pink; color:#bf2c9f;', _this.userData)
				} else {
					uni.showToast({
						title: res.msg || '获取用户信息失败',
						icon: 'none'
					});
				}

			});

			console.log('%c [ userData ]-61', 'font-size:13px; background:pink; color:#bf2c9f;', this.userData)

		},
		getUserDetail() {
			var _this = this;
			_this._post_form('api/user/getUserDetail', {}, function (result) {
				_this.setData({
					userInfo: result.data
				})
			});
		},
		goLogin() {
			if (!this.login) {
				uni.navigateTo({
					url: 'login'
				});
			}
		},
		gourl(url) {
			if (this.login) {
				uni.navigateTo({
					url: url
				});
			} else {
				uni.navigateTo({
					url: 'login'
				});
			}
		},

		onChat() {
			plus.runtime.openURL('mqqwpa://im/chat?chat_type=crm&uin=2903475819',
				function (res) {
					plus.nativeUI.alert("本机没有安装QQ，无法启动");
				});
		},
		onClickUrl() {
			this.openBrowser('https://www.huzhan.com/code/goods403940.html');
		},

	}
}
</script>

<style>
.workData {
	margin: 20upx;
	color: #fff;
	border-radius: 20rpx;
	padding: 30upx;
	background: linear-gradient(270deg, #2E3A76 0%, #5669BE 100%);

}

.performance {
	display: flex;
	margin-top: 20rpx;
	margin-bottom: 20rpx;
	justify-content: space-around;

}

.performance-item {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.m_top20 {
	margin-top: 20px;
}

.center {
	flex-direction: column;
}

.logo {
	/* height: 120px;
		padding: 10px;
		background-color: #2fc25b;
		display: flex; */
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;
	background-image: url("../../static/my-bg1.jpg");
	background-size: 100% 100%;
	width: 100%;
	height: 400rpx;
}

.logo-hover {
	opacity: 0.8;
}

.logo-img {
	width: 150upx;
	height: 150upx;
	border-radius: 150upx;

}

.logo-title {
	height: 115rpx;
	align-items: center;
	justify-content: space-between;
	flex-direction: row;
	margin-left: 20upx;
}

.uer-name {
	height: 60upx;
	line-height: 60upx;
	font-size: 38upx;
	color: #FFFFFF;
	line-height: 75px;
}

.btn {
	position: initial;
	padding-left: 0px;
	padding-right: 0px;
}
</style>